package com.lenovo.smarttraffic.ui.activity.stage2;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.Nullable;
import android.support.v7.widget.Toolbar;
import android.view.View;

import com.lenovo.smarttraffic.R;
import com.lenovo.smarttraffic.ui.activity.BaseActivity;

public class ETCManageActivity extends BaseActivity {


    private Handler handler = new Handler();

    private View icon;
    private boolean flag = true;

    @Override
    protected int getLayout() {
        return R.layout.activity_etc_manage;
    }

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        initView();
        initData();
    }

    public void initView() {
        Toolbar mToolbar = findViewById(R.id.toolbar);
        mToolbar.setNavigationOnClickListener(view -> finish());

        icon = findViewById(R.id.icon);
        startLoop();

        findViewById(R.id.etc_charge).setOnClickListener(v -> startActivity(new Intent(this, ETCChargeActivity.class)));

        findViewById(R.id.etc_money).setOnClickListener(v -> startActivity(new Intent(this, ETCMoneyActivity.class)));

        findViewById(R.id.charge_history).setOnClickListener(v -> startActivity(new Intent(this, ETCChargeHistoryActivity.class)));

    }

    public void initData() {


    }


    private void startLoop() {
        handler.postDelayed(() -> {
            if (icon != null) {
                icon.setBackgroundResource((flag = !flag) ? R.mipmap.sound_1 : R.mipmap.sound_2);
                startLoop();
            }
        }, 1000);

    }


}
